﻿@model Node
@{
    Theme theme = Ext.Net.Theme.Neptune;

    if (Session["Ext.Net.Theme"] != null)
    {
        theme = (Theme) Session["Ext.Net.Theme"];
    }

    List<CheckMenuItem> themeItems = new List<CheckMenuItem>()
    {
        new CheckMenuItem
        {
            Text = "Default",
            Group = "theme"
        },
        new CheckMenuItem
        {
            Text = "Gray",
            Group = "theme"
        },
        new CheckMenuItem
        {
            Text = "Access",
            Group = "theme"
        },
        new CheckMenuItem
        {
            Text = "Neptune",
            Group = "theme"
        }
    };

    string themeName = theme.ToString();

    themeItems.First<CheckMenuItem>(item => item.Text == themeName).Checked = true;

    ResourceManager.RegisterControlResources<TagLabel>();
}
@{
    var x = Html.X();
    x.TreePanel()
        .TopBar(
            new Toolbar
            {
                Items =
                {
                    new TextField
                    {
                        ID = "SearchField",
                        AutoFocus = true,
                        EnableKeyEvents = true,
                        Flex = 1,
                        EmptyText = "Filter Examples...",
                        Triggers =
                        {
                            new FieldTrigger
                            {
                                HideTrigger = true,
                                Icon = TriggerIcon.Clear
                            }
                        },
                        Listeners =
                        {
                            KeyUp =
                            {
                                Buffer = 100,
                                Fn = "keyUp"
                            },
                            TriggerClick =
                            {
                                Fn = "clearFilter"
                            },
                            SpecialKey =
                            {
                                Fn = "filterSpecialKey",
                                Delay = 1
                            }
                        }
                    },
                    new Button
                    {
                        Icon = Icon.Cog,
                        ToolTip = "Options",
                        Menu =
                        {
                            new Menu
                            {
                                Items =
                                {
                                    new MenuItem
                                    {
                                        Text = "Expand All",
                                        IconCls = "icon-expand-all",
                                        Handler = "this.up('treepanel').expandAll(false);"
                                    },
                                    new MenuItem
                                    {
                                        Text = "Collapse All",
                                        IconCls = "icon-collapse-all",
                                        Handler = "this.up('treepanel').collapseAll(false);"
                                    },
                                    new MenuSeparator(),
                                    new CheckMenuItem
                                    {
                                        Text = "NEW Only",
                                        CheckHandler = "filterNewExamples"
                                    },
                                    new CheckMenuItem
                                    {
                                        Text = "Debug Mode",
                                        CheckHandler = "function (item, checked) { App.direct.ChangeScriptMode(checked); }",
                                        Checked = MvcResourceManager.GetInstance().SourceFormatting
                                    },
                                    new MenuSeparator(),
                                    new MenuItem
                                    {
                                        Text = "Theme",
                                        Icon = Icon.Paintcan,
                                        Menu =
                                        {
                                            new Menu
                                            {
                                                Items =
                                                {
                                                    themeItems
                                                },
                                                Listeners =
                                                {
                                                    Click =
                                                    {
                                                        Fn = "themeChange"
                                                    }
                                                }
                                            }
                                        }
                                    },
                                    new MenuSeparator(),
                                    new MenuItem()
                                    {
                                        Text = "Search by",
                                        Icon = Icon.Find,
                                        Menu =
                                        {
                                            new Menu()
                                            {
                                                Items =
                                                {
                                                    new CheckMenuItem()
                                                    {
                                                        ID = "SearchByTitles",
                                                        Checked = true,
                                                        Text = "Titles"
                                                    },
                                                    new CheckMenuItem()
                                                    {
                                                        ID = "SearchByTags",
                                                        Checked = true,
                                                        Text = "Tags"
                                                    }
                                                }
                                            }
                                        }
                                    },
                                    new MenuItem()
                                    {
                                        Text = "Tag Cloud",
                                        Icon = Icon.WeatherClouds,
                                        Listeners =
                                        {
                                            Click =
                                            {
                                                Fn = "showTagCloud"
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        )
        .Border(false)
        .Root(Html.X().Node().NodeID("0").Text("Root"))
        .RootVisible(true)
        .Listeners(li => { li.ItemClick.Handler = "onTreeItemClick(record, e);"; });
}